var bmap = require('../../libs/bmap-wx.js'); 
var wxMarkerData = []; 
Component({

    behaviors: [],

    data: {
        markers: [], 
        latitude: '', 
        longitude: '', 
        placeData: {} 
    }, // 私有数据，可用于模版渲染
  
    lifetimes: {
        attached: function() {  
            var that = this 
            // 新建百度地图对象  
           
            var BMap = new bmap.BMapWX({ 
                ak: 'Q0jQhImqll38X34icliVDTjoftENHm4e' 
            }); 
           
            var fail = function(data) { 
                console.log(data) 
            }; 
            var success = function(data) { 
                wxMarkerData = data.wxMarkerData; 
                that.setData({ 
                    markers: wxMarkerData 
                }); 
                that.setData({ 
                    latitude: wxMarkerData[0].latitude 
                }); 
                that.setData({ 
                    longitude: wxMarkerData[0].longitude 
                }); 
            } 
           // 发起POI检索请求 
            BMap.search({ 
                "query": '酒店', 
                fail: fail, 
                success: success, 
            }); 
        }
    },
  
  
    pageLifetimes: {

    },
  
    methods: {
        makertap: function(e) { 
            var that = this; 
            var id = e.markerId; 
            that.showSearchInfo(wxMarkerData, id); 
            that.changeMarkerColor(wxMarkerData, id); 
        }, 
        showSearchInfo: function(data, i) { 
            var that = this; 
            that.setData({ 
                placeData: { 
                    title: '名称：' + data[i].title + '\n', 
                    address: '地址：' + data[i].address + '\n', 
                    telephone: '电话：' + data[i].telephone 
                } 
            }); 
        }, 

    }
  
  })